package cn.edu.zut.internship.web.controller.result;

import cn.edu.zut.internship.bean.sys.Result;
import cn.edu.zut.internship.bean.sys.SysUser;
import cn.edu.zut.internship.iservice.result.ResultSV;
import cn.edu.zut.internship.web.utils.UserInfoUtil;
import com.alibaba.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;
@RestController
@RequestMapping("/result")
public class ResultController {
    @Reference
    ResultSV resultSV;

    /**
     * 学生获取成绩列表
     * @param params
     * @return
     */
    @RequestMapping("/getMyResultList")
    public Result getMyResultList(@RequestBody Map params) {
        Result result = new Result();
        SysUser userInfo = UserInfoUtil.getUserInfo();
        params.put("studentAccount",userInfo.getUserAccount());
        result = resultSV.getMyResultList(params);
        return result;
    }

    /**
     * 学生获取成绩详情
     * @param
     * @return
     */
    @RequestMapping("/getMyResult")
    public Result getMyResult() {
        Result result = new Result();
        Map params = new HashMap();
        SysUser userInfo = UserInfoUtil.getUserInfo();
        params.put("studentAccount",userInfo.getUserAccount());
        result = resultSV.getMyResult(params);
        return result;
    }
    /**
     * 教师给学生的报告审核打分
     * @param params
     * @return
     */
    @RequestMapping("/reportResult")
    public Result reportResult(@RequestBody Map params) {
        Result result = new Result();
        SysUser userInfo = UserInfoUtil.getUserInfo();
        params.put("teachAccount",userInfo.getUserAccount());
        result = resultSV.reportResult(params);
        return result;
    }

    /**
     * 教师或管理员查询所有学生成绩
     * @param params
     * @return
     */
    @RequestMapping("/selectRsultList")
    public Result selectRsultList(@RequestBody Map params) {
        Result result = new Result();
        SysUser userInfo = UserInfoUtil.getUserInfo();
        params.put("userInfo",userInfo);
        result = resultSV.selectRsultList(params);
        return result;
    }

    /**
     * 教师或管理员导出所有学生成绩
     * @param params
     * @return
     */
    @RequestMapping("/exportResult")
    public Result exportResult(@RequestBody Map params) {
        Result result = new Result();
        SysUser userInfo = UserInfoUtil.getUserInfo();
        params.put("userInfo",userInfo);
        result = resultSV.exportResult(params);
        return result;
    }
    /**
     * 获取报告成绩信息
     * @param params
     * @return
     */
    @RequestMapping("/getReportResult")
    public Result getReportResult(@RequestBody Map params) {
        Result result = new Result();
        SysUser userInfo = UserInfoUtil.getUserInfo();
        params.put("userInfo",userInfo);
        result = resultSV.getReportResult(params);
        return result;
    }

    /**
     * 获取学生成绩组成详情
     * @param params
     * @return
     */
    @RequestMapping("/detail")
    public Result detail(@RequestBody Map params) {
        Result result = new Result();
        SysUser userInfo = UserInfoUtil.getUserInfo();
        params.put("userInfo",userInfo);
        result = resultSV.detail(params);
        return result;
    }
}
